package org.vgou.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * 
 * Copyright (c) 2011, vgou All rights reserved.
 * 
 * @since Nov 27, 2011
 * @author <a href="mailto:jason.hxx@gmail.com">jason</a>
 * @version Id: Order.java Nov 27, 2011
 * @comment 订单实体类
 * 
 */
@Entity
// 更新一个对象时,会生成动态SQL,当属性值发生变化时，才会包含到UPDATE语句中
@org.hibernate.annotations.Entity(dynamicUpdate = true, dynamicInsert = true)
@Table(name = "productorder")
public class Order implements Serializable {

	private static final long serialVersionUID = -1726082215467744456L;

	/** 编号 **/
	@Id
	@Column(name="id", length=19)
	private long id;
	
	/** 订单号 **/
	@Column(name="orderid", length=19, nullable=false)
	private long orderId;
	
	/** 下单时间 **/
	@Column(name="ordertime",nullable=false)
	private Date orderTime = new Date();
	
	/** 数量 **/
	@Column(name="amount",nullable=false)
	private int amount = 0;
	
	/** 总价 **/
	@Column(name="total",nullable=false)
	private float total = 0;
	
	
	/** 状态  1 未发货 2 已发货  3 团购成功 4已评价**/
	@Column(name="status", length=10, nullable=false)
	private int status = 1;
	
	/** 快递名称  **/
	@Column(name="expressname")
	private String expressName;
	
	/** 快递单号  **/
	@Column(name="expressid")
	private String expressID;
	
	/** 特殊要求 **/
	@Column(name="special")
	private String special;
	
	/** 评分 **/
	@Column(name="grade")
	private int grade = 0;
	
	/** 评价 **/
	@Column(name="evaluate")
	private String evaluate;
	
	/** 产品 **/
	@ManyToOne(fetch=FetchType.EAGER, cascade=CascadeType.ALL)
	@JoinColumn(name="productid")
	private Product product;
	
	/** 收货地址 **/
	@ManyToOne(fetch=FetchType.EAGER, cascade=CascadeType.ALL)
	@JoinColumn(name="shippingaddressid")
	private ShippingAddress shippingAddress;

	public Order() {
		super();
	}

	public Order(long id, long orderId, Date orderTime, int amount, float total, int status,
			String expressName, String expressID, String special, int grade,
			String evaluate, Product product, ShippingAddress shippingAddress) {
		super();
		this.id = id;
		this.orderId = orderId;
		this.orderTime = orderTime;
		this.amount = amount;
		this.total = total;
		this.status = status;
		this.expressName = expressName;
		this.expressID = expressID;
		this.special = special;
		this.grade = grade;
		this.evaluate = evaluate;
		this.product = product;
		this.shippingAddress = shippingAddress;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public long getOrderId() {
		return orderId;
	}

	public void setOrderId(long orderId) {
		this.orderId = orderId;
	}

	public Date getOrderTime() {
		return orderTime;
	}

	public void setOrderTime(Date orderTime) {
		this.orderTime = orderTime;
	}

	public int getAmount() {
		return amount;
	}

	public void setAmount(int amount) {
		this.amount = amount;
	}

	public float getTotal() {
		return total;
	}

	public void setTotal(float total) {
		this.total = total;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public String getExpressName() {
		return expressName;
	}

	public void setExpressName(String expressName) {
		this.expressName = expressName;
	}

	public String getExpressID() {
		return expressID;
	}

	public void setExpressID(String expressID) {
		this.expressID = expressID;
	}

	public String getSpecial() {
		return special;
	}

	public void setSpecial(String special) {
		this.special = special;
	}

	public int getGrade() {
		return grade;
	}

	public void setGrade(int grade) {
		this.grade = grade;
	}

	public String getEvaluate() {
		return evaluate;
	}

	public void setEvaluate(String evaluate) {
		this.evaluate = evaluate;
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public ShippingAddress getShippingAddress() {
		return shippingAddress;
	}

	public void setShippingAddress(ShippingAddress shippingAddress) {
		this.shippingAddress = shippingAddress;
	}

}
